﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Hosting;

namespace HR.HrHelper
{
    public class FileHelper
    {
        /// <summary>
        /// 通过图片地址获取图片数据流
        /// </summary>
        /// <param name="PicturePath"></param>
        /// <returns></returns>
        public static object GetImgInfo(string PicturePath)
        {
            //将需要存储的图片读取为数据流
            try
            {
                if (File.Exists(HostingEnvironment.MapPath("~/") + @PicturePath) == false)
                {
                    return "null";
                }
                FileStream fs = new FileStream(HostingEnvironment.MapPath("~/") + @PicturePath, FileMode.Open, FileAccess.Read);
                Byte[] btye2 = new byte[fs.Length];
                fs.Read(btye2, 0, Convert.ToInt32(fs.Length));
                fs.Close();
                return btye2;
            }
            catch (Exception)
            {

                throw;
                
            }

            //将数据流读取为图片
            //System.IO.MemoryStream ms = new System.IO.MemoryStream(btye2);
            //System.Drawing.Image img = System.Drawing.Image.FromStream(ms);

        }
    }
}